<template>
    <div class="app-container">
        <el-form :model="queryParams" inline label-width="90px">
            <el-form-item prop="keyword" label="关键词">
                <el-input style="width:240px;" v-model="queryParams.userName" placeholder="请输入关键词" />
            </el-form-item>
            <el-form-item>
                <el-button :loading="loading" type="primary" @click="handleQuery">搜索</el-button>
                <el-button :loading="loading" @click="handleReset">重置</el-button>
            </el-form-item>
        </el-form>
        <el-table :data="dataList" :loading="loading">
            <el-table-column align="center" prop="name" show-overflow-tooltip label="企业名称">
                <template #default="{ row }">
                    <el-button type="text" :loading="loading" @click="handleToDetails(row)">{{ row.name }}</el-button>
                </template>
            </el-table-column>
            <el-table-column show-overflow-tooltip align="center" prop="legalName" label="法人名称" width="120" />
            <el-table-column show-overflow-tooltip align="center" prop="organizationType" label="企业类型" />
            <el-table-column show-overflow-tooltip align="center" prop="registerAddress" label="注册地址" />
            <el-table-column show-overflow-tooltip align="center" prop="taxLevel" label="纳税等级" width="100" />
            <el-table-column show-overflow-tooltip align="center" prop="queryTime" label="查询日期" width="140" />
            <el-table-column show-overflow-tooltip align="center" prop="queryName" label="查询人" width="120" />
            <el-table-column show-overflow-tooltip align="center" prop="authorizeStatus" label="授权状态" width="100"
                :formatter="row => authorizeStatusEnum[row.authorizeStatus]" />
            <el-table-column show-overflow-tooltip align="center" prop="taxpayerId" label="企业税号" />
        </el-table>
        <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize"
            @pagination="getList" />
    </div>
</template>

<script setup name="TaxReportManage">
import { getRpReportList } from '@/api/taxReportManage';
import { authorizeStatusEnum } from '@/utils/enum';
const { proxy } = getCurrentInstance()
const route = useRoute()
const router = useRouter()
const queryParams = ref({
    pageNo: 1,
    pageSize: 10,
})
const total = ref(0)
const loading = ref(false)
const dataList = ref([])

getList()
function getList() {
    const reqForm = JSON.parse(JSON.stringify(queryParams.value))
    loading.value = true
    getRpReportList(reqForm).then(res => {
        dataList.value = res.data || []
        total.value = res.totalCount
    }).finally(() => loading.value = false)
}
function handleQuery() {
    queryParams.value.pageNo = 1
    getList()
}
function handleReset() {
    queryParams.value = {
        pageNo: 1,
        pageSize: 10,
    }
    getList()
}


// 跳转详情
function handleToDetails(row) {
    const query = { path: route.path, id: row.id }
    router.push({ path: '/taxReportDetails', query })
}

</script>

<style lang="scss" scoped></style>